package es.onlysolutions.gs.comm.dao.hb;

import es.onlysolutions.arq.core.accesobd.GenericHbDao;
import es.onlysolutions.gs.comm.entity.User;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

/**
 * Hibernate dao for user entities.
 */
public class UserHbDao extends GenericHbDao
{

    /**
     * Get a User entity from his login.
     * @param login The unique login.
     * @return The User entity from the database.
     */
    public User userByLogin( String login )
    {
        Criteria criteria = getCriteria( User.class );
        criteria.add( Restrictions.eq("login", login) );
        return (User) criteria.uniqueResult();
    }
}
